import { http } from "@/utlis"
import type { ResType } from "./shared"
export type ChannelItem = {
  id: number
  name: string
}

type ChannelRes = {
  channels: ChannelItem[]
}

export function fetchChannelAPI() {
  return http.request<ResType<ChannelRes>>({
    url: '/v1_0/channels',
  })
}


//请求文章列表

type ListItem = {
  art_id: string
  title: string
  aut_id: string
  comm_count: number
  pubdate: string
  aut_name: string
  is_top: number
  cover: {
    type: number
    images: string[]
  }
}

export type ListRes = {
  results: ListItem[]
  pre_timestamp: string
}

type ResParams = {
  channel_id: string
  timestamp: string
}

export function fetchListAPI(params: ResParams) {
  return http.request<ResType<ListRes>>({
    url: '/v1_0/articles',
    params
  })
}